<%--
退费主页面，负责退费项的添加、删除和保存退费交易
@author <a href="mailto:chenfenghai@ceopen.cn">chenfenghai</a>
action ：cashieringAction
method ：initRefundMain
created ：2010-10-26
--%>
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/validation.jsp"%>
<%@ include file="/commons/dateTime.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script type="text/javascript">
	var refundId = null;
	//设置选择ID
	function setSelectRefundId(id){
		refundId = id;
	}
	//设置退费金额
	function setCredit(creditValue){
		$('credit').value = creditValue;
		$('spanCredit').innerHTML = '<input type=\"text\" id=\"creditView\" name=\"creditView\" style=\"text-align: right\" readonly=\"readonly\" value=\"'+creditValue+'\" size=\"16\" />';
	}
	//设置退费项的总数
	function setTotalRows(totalRowsValue){
		$('totalRows').value = totalRowsValue;
	}
	//打开新增页面
	function openAddRefund(){
		var url = "${ctx}/charge_cashieringAction.do?method=initRefundAdd&houseId=${houseId}&houseNumber=${houseNumber}&isVirtual=${isVirtual}&accountId=${accountId}&proRightId=${proRightId}";
		top.windowOpen(url, 'refundAdd', '退费',300, 450,  true, "refundAdd");
	}
	//提示是否删除信息
	function showDelete(){
		if( refundId == null ){
			ErrorAlert('${key.tipsByDelete}');
		}else{
			AlarmConfirm('${key.tipsByDeleteConfirm}',"refundList","deleteRecord");
		}
	}
	//重新加载列表数据
	function reloadRefunds(){
		refundId = null;
		$('refundList').src="${ctx}/charge_cashieringAction.do?method=initRefundList";
	}
	//关闭窗口
	function closewin(){
		windowClose();
	}
	//退费交易提交
	function refundTradeSubmit(){
		if($("totalRows").value == null || $("totalRows").value == "" || parseInt($("totalRows").value) <= 0){
			ErrorAlert("请添加退费项目与退费金额！");
			return;
		}
		var isTrue=$('refundTradeForm').fireEvent("onSubmit") ;
		//验证不通过
	    if(!isTrue){
		    return;
	    }else if(($("description").value == null) || ($("description").value.length == 0) || /^\s+$/.test($("description").value)){
			ErrorAlert("请输入交易摘要！");
			return;
	    }
		var param = Form.serialize('refundTradeForm');
		new Ajax.Request($('refundTradeForm').action,{method: 'post',parameters :param ,onSuccess : showResponse});
	}
	function showResponse(response){
		//alert("退费成功！");return;
		ajaxSubmitException(response.responseText);
		if("true" == response.responseText){
			findFrame("connTabPanel").refresh();
			windowClose();
		}
	}
</script>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="window_head_outBg">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td><span class="window_head_intext"><img
					src="${ctx}/images/ico_Advance.gif" align="absmiddle" />&nbsp;退费</span></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="aux_header_line_1"></td>
	</tr>
	<tr>
		<td class="aux_header_line_2"></td>
	</tr>
	<tr>
		<td valign="middle" class="content">
		<table width="100%" border="0" cellpadding="0" cellspacing="1">
			<tr>
				<td>
				<div>
				<table width="100%" border="0" cellpadding="0" cellspacing="0"
					class="tab_line">
					<tr>
						<td class="bg_toolBar">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="35%">&nbsp;</td>
								<td width="65%" align="right"><!--------------------------右边图标01----------------------------------->
								<table border="0" cellpadding="0" cellspacing="0" id="ico1">
									<tr>
										<td class="toolbarico"><a href="javascript:void(0);"
											onClick="openAddRefund()" onFocus="this.blur()"><img
											src="${ctx}/images/ico_newfile.gif" alt="新增" width="16"
											height="16" border="0" align="absbottom" />&nbsp;</a></td>
										<td class="toolbarico"><a href="javascript:void(0);"
											onClick="showDelete()" onFocus="this.blur()"><img
											src="${ctx}/images/ico_delete.gif" alt="删除" width="16"
											height="16" border="0" align="absbottom" /></a></td>
										<td class="toolbarico">&nbsp;</td>
									</tr>
								</table>
								</td>
							</tr>
						</table>
						</td>
					</tr>
					<tr>
						<td valign="top"><iframe
							src="${ctx}/charge_cashieringAction.do?method=initRefundList"
							name="refundList" id="refundList" width="100%" height="300px"
							frameborder="0" scrolling="auto"> </iframe></td>
					</tr>
				</table>
				</div>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td>
		<form action="${ctx}/charge_cashieringAction.do?method=addRefund"
			name="refundTradeForm" method="post" class="required-validate">
		<input type="hidden" name="isVirtual" value="${isVirtual}"> <input
			type="hidden" name="chargeRecords" value="${chargeRecords }">
		<input type="hidden" name="payMode" value="${payMode }"> <input
			type="hidden" name="credit" value="${credit }"> <input
			type="hidden" name="notCredit" value="${notCredit }"> <input
			type="hidden" id="houseNumber" name="houseNumber"
			value="${houseNumber }" /> <input type="hidden"
			name="accountHouseId" value="${accountHouseId}"> <input
			type="hidden" id="totalRows" name="totalRows" /> <input
			type="hidden" id="periodId" name="periodId" value="${periodId }" /><input
			type="hidden" id="coalitionHouseId" name="coalitionHouseId"
			value="${coalitionHouseId }" />
		<table>
			<tr>
				<td class="aux_intable_td1">支付交易码：</td>
				<td class="aux_intable_require"><select id="businessId"
					name="businessId" style="width: 110px;">
					<c:forEach items="${codeList}" var="code">
						<option value="${code.keyword}">${code.bizCode
						}-${code.description}</option>
					</c:forEach>
				</select></td>
				<td class="aux_intable_td1">支付金额：</td>
				<td class="aux_intable_td2"><span id="spanCredit"> <input
					type="hidden" id="credit" name="credit" /> <input type="text"
					id="creditView" name="creditView" style="text-align: right"
					readonly="readonly" value="0.00" size="16" /></span>元</td>
			</tr>
			<tr>
				<td height="64" class="aux_intable_td1">交易摘要：</td>
				<td colspan="3" class="aux_intable_require_more"><textarea
					id="description" name="description" cols="60" rows="3"
					class="textareatext required max-length-50"
					afterInsert="descriptionTip"></textarea><span id="descriptionTip"></span></td>
			</tr>
		</table>
		</form>
		</td>
	</tr>
	<tr>
		<td colspan="2" class="window_footer">
		<table border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td>
				<table border="0" cellpadding="0" cellspacing="0"
					onclick="refundTradeSubmit();">
					<tr>
						<td class="buttonOffLeft" id="btn1_21"></td>
						<td class="buttonOffMiddle" id="btn1_22"
							onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)"
							onblur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif"
							alt="" width="14" height="14" border="0" align="absbottom" /> 确
						定</td>
						<td class="buttonOffRight" id="btn1_23"></td>
					</tr>
				</table>
				</td>
				<td class="btn_between_space"></td>
				<td>
				<table border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td class="buttonOffLeft" id="btn1_31"></td>
						<td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();"
							onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)"
							onblur="btn_change(3)"><img
							src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14"
							border="0" align="absbottom" /> 关 闭</td>
						<td class="buttonOffRight" id="btn1_33"></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		<p>&nbsp;</p>
		</td>
	</tr>
</table>
</body>
</html>